'''
pattern furry
将 diff ZipArchive 汇集到 images ZipArchive
'''
# dates = ['0729','0730','0731','0801','0804',]
# dates = ['0813']
# dates = [
#     '0808',
#     '0811','0812','0813','0814','0815',
#     '0818','0819','0820','0821','0822',
#     '0825',
#     ]
# dates = [
#     '0826','0827','0828','0829',
#     '0901','0902','0903','0904','0905',
#     ]
dates = [
    # '0908','0909','0910',
    "0911","0912",
    "0915","0916",'0917'
    ]

categories = ['coat' , 'sweater' , 'leather']
sub_categoryies = ['pattern','furry']
# categories = ['sweater' , 'leather']
# categories = ['leather']


from tqdm import tqdm
import os,shutil
from util_for_os import ose,osj

dir = '/mnt/nas/datasets/diction'
get_tar_dir = lambda sub_category : osj( dir , f'images_{sub_category}' )
get_source_dir = lambda category , date , sub_category : osj( dir , f'{category}{date}_img_clo_diff_{sub_category}' )



# 先确认路径存在
for category in categories:
    
    for date in dates:

        if date >= '0826' and category == 'leather':
            continue
        
        for sub_category in sub_categoryies:
            
            source_dir = get_source_dir(category , date , sub_category)
            tar_dir = get_tar_dir( sub_category )
            
            name_path = osj( source_dir , 'names.txt' )
            


            assert ose( source_dir ),source_dir
            assert ose( tar_dir ),tar_dir
            assert ose( name_path ),name_path



# import pdb
# pdb.set_trace()

for category in categories:
    
    for date in dates:
        if date > '0826' and category == 'leather':
            continue
        
        for sub_category in sub_categoryies:
            
            source_dir = get_source_dir(category , date , sub_category)
            tar_dir = get_tar_dir( sub_category )
            
            name_path = osj( source_dir , 'names.txt' )
            

            with open( name_path , encoding='utf-8' ) as f:
                names = f.readlines()
                
            for name in tqdm(names):
                name = name.strip()
                if not name.endswith( '.jpg' ):continue
                
                source_path = osj( source_dir , name )
                
                if not ose(source_path):
                    print('not exists !! >> ',source_path)
                    continue
                
                shutil.copy2( source_path , tar_dir )


